window.onload = function(){
    jsona = JSON.parse(sessionStorage.getItem('jsona'));
    console.log(jsona[0].getOrConsigee);
    document.getElementById("orderId").value=jsona[0].orderId;
    document.getElementById("custPhone").value=jsona[0].custPhone;
    document.getElementById("accountNo").value=jsona[0].accountNo;
    document.getElementById("productQR").value=jsona[0].productQR;
    document.getElementById("productName").value=jsona[0].productName;
    document.getElementById("productPhoto").innerHTML = "<img width='100px' height='100px' src=\"data:image/jpg;base64," + jsona[0].productPhoto + "\">";
    document.getElementById("buyNumber").value=jsona[0].buyNumber;
    $("#orderTime").val(jsona[0].orderTime);
    document.getElementById("price").value=jsona[0].price;
    document.getElementById("realPayPrice").value=jsona[0].realPayPrice;
    document.getElementById("shproductState").value=jsona[0].orderState;
    document.getElementById("consigeeAddr").value=jsona[0].consigeeAddr;
    document.getElementById("qhproductState").value=jsona[0].State;
    $(".getOrConsigee").val(jsona[0].getOrConsigee);//默认送货，取货为1
    var sh_Addr = document.getElementById("sh_Addr"); //送货地址
    var qh_state=document.getElementById("qh_state");//取货
    var sh_state=document.getElementById("sh_state");//送货
    sh_Addr.style.display = (getOrConsigee.value == "1" ) ? "none" : "block";
    qh_state.style.display= (getOrConsigee.value == "1" ) ? "block" : "none";
    sh_state.style.display= (getOrConsigee.value == "1" ) ? "none" : "block";
}
var jsona=[];

function layer_close() {
    // var jsonAll = JSON.parse(sessionStorage.getItem('jsonAll'));
    // sessionStorage.setItem('jsonAll', jsonAll);
    window.location.href = "purchaseOrderManage.html";
}
function isError(){
    var custphone=document.getElementById("custPhone").value;
    if(!(/^1[34578]\d{9}$/.test(custphone))){
        alert("手机号码有误，请重填");
        return false;
    }
}

function submit() {
    var custPhone=document.getElementById("custPhone").value;
    var productQR=document.getElementById("productQR").value;
    if(custPhone==jsona[0].custPhone){custPhone="";}
    var orderId = document.getElementById("orderId").value;
    var getOrConsigeeSe=document.getElementById("getOrConsigee");
    var getOrConsigees = getOrConsigeeSe.options[getOrConsigeeSe.selectedIndex].value;
    var getOrConsigee="";
    if(getOrConsigees=="送货"){
        getOrConsigee="0"
    }else{
        getOrConsigee="1"
    }
    var consigeeAddr=document.getElementById("consigeeAddr").value;
    var accountNo = document.getElementById("accountNo").value;
    var State="";

    if(getOrConsigees=="送货"){
        var StateSe=document.getElementById("shproductState");
        var States=StateSe.options[StateSe.selectedIndex].value;
        if(States==1){State="1";}
        else if(States==2){State="2";}
        else if(States==3){State="3";}
        else if(States==0){State="0";}
    }else{
        var StateSe=document.getElementById("qhproductState");
        var States=StateSe.options[StateSe.selectedIndex].value;
        if(States==1){State="1";}
        else if(States==2){State="2";}
        else if(States==3){State="0";}
        document.getElementById("consigeeAddr").innerText="";
    }
    if()
    var date = "custPhone="+ custPhone +"&getOrConsigee="+ getOrConsigee +"&state="+ State +"&consigeeAddr="+ consigeeAddr
        +"&orderId="+ orderId +"&accountNo="+ accountNo + "&productQR="+ productQR;
    var url = "purchase!modifyOrder";
    sendRequest("post", url, date, modifyResult);
}
function modifyResult(result) {
    var rs = eval("(" + result + ")") ;
    if(rs == "success")
    {
        alert("修改成功");
        window.location.href = "purOrderDetailManager.html";
    }
}